//
//  SLVIPViewModel.m
//  StarLight
//
//  Created by Duke.wu on 16/6/8.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLVIPViewModel.h"
#import "SLNetWork.h"


@implementation SLVIPViewModel



- (void)getVIPPrice{
  @weakify(self)
  NSString *url = [NSString stringWithFormat:@"%@/sys/vippricelist?uid=%@",baseUrl,[DEFAULTS objectForKey:loginInfo][@"id"]];
  
  [SLNetWork getDataWithRequest:url complete:^(id respond, NSError *error) {
    if (!error) {
      @strongify(self)
      NSMutableArray *priceArr = [SLVIPPriceModel mj_objectArrayWithKeyValuesArray:respond[@"data"]];
      
      NSMutableArray *arr1 = [NSMutableArray arrayWithCapacity:1];
      NSMutableArray *arr2 = [NSMutableArray arrayWithCapacity:1];
      NSMutableArray *arr3 = [NSMutableArray arrayWithCapacity:1];
      NSMutableArray *arr4 = [NSMutableArray arrayWithCapacity:1];
      NSMutableArray *arr5 = [NSMutableArray arrayWithCapacity:1];
      
      for (SLVIPPriceModel *model in priceArr) {
        
        switch (model.star) {
          case 1:{
            [arr1 addObject:model];
          }
            break;
          case 2:{
            [arr2 addObject:model];
          }
            break;
          case 3:{
            [arr3 addObject:model];
          }
            break;
          case 4:{
            [arr4 addObject:model];
          }
            break;
          case 5:{
            [arr5 addObject:model];
          }
            break;
          default:
            break;
        }
      }
      
      self.start1Arr = arr1;
      self.start2Arr = arr2;
      self.start3Arr = arr3;
      self.start4Arr = arr4;
      self.start5Arr = arr5;
      
    }
  }];
}



- (void)payWithStar:(NSInteger)star channel:(NSString *)channel time:(NSInteger)time block:(returnCharge)block{
  
  NSString *url = [NSString backUrlWithService:@"sys" methodName:@"vipplay"];
  NSDictionary *para = @{@"mac" : [NSUUID UUID].UUIDString,
                         @"star":@(star),
                         @"channel":channel,
                         @"time":@(time),
                         @"uid":[DEFAULTS objectForKey:loginInfo][@"id"]};
  
  [SVProgressHUD showWithStatus:@"正在付款"];
  [SLNetWork postDataWithParameters:para postUrl:url complete:^(id respond, NSError *error) {
    if (!error) {
      block(respond[@"charge"]);
    }
  }];
  
}


- (NSMutableArray *)start1Arr{
  if (!_start1Arr) {
    _start1Arr = [NSMutableArray arrayWithCapacity:1];
  }
  return _start1Arr;
}

- (NSMutableArray *)start2Arr{
  if (!_start2Arr) {
    _start2Arr = [NSMutableArray arrayWithCapacity:1];
  }
  return _start2Arr;
}

- (NSMutableArray *)start3Arr{
  if (!_start3Arr) {
    _start3Arr = [NSMutableArray arrayWithCapacity:1];
  }
  return _start3Arr;
}

- (NSMutableArray *)start4Arr{
  if (!_start4Arr) {
    _start4Arr = [NSMutableArray arrayWithCapacity:1];
  }
  return _start4Arr;
}

- (NSMutableArray *)start5Arr{
  if (!_start5Arr) {
    _start5Arr = [NSMutableArray arrayWithCapacity:1];
  }
  return _start5Arr;
}


@end








@implementation SLVIPPriceModel


@end